Using toggle buttons
Toggle button is an object that can have multiple toggle states you can use to create interactions with 3D content through clicking.
Toggle button does not have a visual shape, so you have to attach to it a 3D object, such as box node, to give the toggle button a shape. When a user clicks the object attached to a toggle button, the action generates a message that travels to the toggle button where you can define the behavior for that message.
The Toggle Button: Toggled Off and Toggle Button: Toggled On message triggers are available by default, but you can add other message as well. For example, to show the difference between the on and off states of a toggle button, you can:
- Switch the material of a mesh.
- Attach two different meshes and switch their visibility.
- Attach two different meshes and fade between the two by animating their Blend Intensity property value.
Creating a toggle button
To create a toggle button:
- In the Project right-click the scene where you want to create a toggle button and select Create > Toggle Button.
- In the Project add a mesh to the toggle button.
For example, right-click the toggle button and select Create > Box.
- In the Project select the toggle button, in the Properties in the Toggle Button: Toggled Off message click the drop-down menu, and select one of the triggers. Triggers you set here are triggered when the state of the toggle button is set to off.
For example, select Set Property and set its properties:
- Repeat the previous step for the Toggle Button: Toggled On message. However, set Fixed Value to a different color.
In the Preview click the mesh you added to the toggle button and as the state of the toggle button changes, so does the color of the mesh.
Adding states to a toggle button
You can set more than two states for a toggle button using the Button: Toggle State message. When a toggle button has more than two states, you cannot use the Toggle Button: Toggled Off and Toggle Button: Toggled On messages to register the state of a toggle button.
To add toggle states to a toggle button:
- Create a toggle button and add a mesh to it.
- In the Project select the toggle button, in the Properties add the Number of Toggle States property, and set it to the number of toggle states you need.
For example, to create three toggle states, enter 3.
- In the Properties click Add Triggers, add a Button: Toggle State message, and select Trigger Settings.
Trigger Settings Editor opens.
- In the Trigger Settings Editor select Add condition.
Trigger Condition Editor window opens.
- In the Trigger Condition Editor window set properties:
- Property to Button Toggle State
- Condition to =
- Fixed Value to the toggle state value with which you want to associate this message.
For example, for the first toggle state value set Fixed Value to 0, for the second to 1, for the third to 2, and so on.
Click Save in Trigger Condition Editor window and the Trigger Settings Editor.
- In the message for which you set the toggle state click the drop-down menu and select one of the triggers. Triggers you set here are triggered when the state of the toggle button layer is set to the condition you defined in the previous step.
For example, select Write Log and enter a message you want to write to the Log window when the toggle button layer reaches this toggle state.
- Add as many messages as there are toggle button layer states and repeat steps 3 to 6.
See also
Using toggle button layers
Using buttons
Using button layers
Buttons
Open topic with navigation